package dd.prog2.exercises.set12.a2;

import java.awt.*;

import javax.swing.*;

@SuppressWarnings("serial")
public class Coin extends JButton {
	int x;
	int y;
	public int color;
	public boolean isEnabled;
	
	public Coin(int x, int y) {
		this.x = x;
		this.y = y;
		this.color = 0;
		this.isEnabled = true;
		// This allows to paint a round background.
		setContentAreaFilled(false);
	}

	// Paint the round background
	protected void paintComponent(Graphics g) {
		
		g.setColor(Color.GREEN);
		if(this.color != 0)
			g.setColor(this.color == 1 ? Color.RED : Color.YELLOW);
		g.fillOval(0, 0, getSize().width - 2, getSize().height - 2);
		super.paintComponent(g);
	}

	public void setEnabled(){
		this.isEnabled = true;
	}
	
	public void setDisabled(){
		this.isEnabled = false;
	}
}